// ===========================================
// Simple effect to texture the given object
// ===========================================

float4x4 gWVP;
float timer = 0.0;
float ttl = 0.2;

struct OutputVS {
    float4 posH   : POSITION0;
	float2 tex0   : TEXCOORD0;
};


OutputVS CircleVS(float4 posL : POSITION0, float2 tex0: TEXCOORD0) {
    // Zero out our output.
	OutputVS outVS = (OutputVS)0;	
	// we are already in screen space
	outVS.posH = posL;
	outVS.tex0 = tex0; 
    return outVS;
}

float stripes(float x, float f, float w) {
  x = (x-0.5) * f;
  x = frac(x);
  x = abs(x * 2 - 1);
  return 1-smoothstep(w, w+.1/f, x);
}

float4 CirclePS(float4 posL : POSITION0,float2 texCoord : TEXCOORD0) : COLOR {    
	float x = 0.1 * stripes(texCoord.y,65.5,0.5);
	if ( x == 0.0 ) {
		if ( timer > 0.0 ) {			
			float c = 1.0 - 0.6 * timer / ttl;
			float a = 0.3;//0.5 - 0.4 * timer / 0.5;
			return float4(c,c,c,a);
		}		
		return float4(0.4,0.4,0.4,0.3);		
	}
	return float4(0.3,0.3,0.3,0.0);			
}

technique CircleTech {

    pass P0 {
        vertexShader = compile vs_2_0 CircleVS();
        pixelShader  = compile ps_2_0 CirclePS();
    }
}
